package com.tplan.tplanrabbitmqserver.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {
    public static final String USER_EMAIL_QUEUE = "user.email.queue";
    public static final String TOPIC_EXCHANGE = "topicExchange";
    public static final String EMAIL_ROUTING_KEY = "user.email";

    @Bean
    public Queue topicQueue1() {
        return new Queue(USER_EMAIL_QUEUE, true);
    }


    @Bean
    public Binding topicBinding1() {
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with(EMAIL_ROUTING_KEY);
    }


    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(TOPIC_EXCHANGE);
    }


}
